<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>财务报表管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnExport").click(function(){
				top.$.jBox.confirm("确认要导出财务数据吗？","系统提示",function(v,h,f){
					if(v=="ok"){
						$("#searchForm").attr("action","${ctx}/ka/kaFinance/export");
						$("#searchForm").submit();
					}
				},{buttonsFocus:1});
				top.$('.jbox-body .jbox-icon').css('top','55px');
				$("#searchForm").attr("action","${ctx}/ka/kaFinance");
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").attr("action","${ctx}/ka/kaFinance");
			$("#searchForm").submit();
        	return false;
        }
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ka/kaFinance/">财务报表列表</a></li>
		<%-- <shiro:hasPermission name="ka:kaFinance:edit"><li><a href="${ctx}/ka/kaFinance/form">财务报表添加</a></li></shiro:hasPermission> --%>
	</ul>
	<form:form id="reportForm" modelAttribute="kaFinance" action="${ctx}/ka/kaFinance/report" method="post" class="breadcrumb form-search">
		<ul class="ul-form">
			<li><label>年份：</label>
				<form:select path="year" class="input-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('year')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>月份：</label>
				<form:select path="month"  class="input-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('month')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li class="btns"><input class="btn btn-primary" type="submit" value="统计"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<form:form id="searchForm" modelAttribute="kaFinance" action="${ctx}/ka/kaFinance/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form" >
			<li style="display:none;"><label>年份：</label>
				<form:select path="year" class="input-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('year')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li style="display:none;"><label>月份：</label>
				<form:select path="month" class="input-medium">
					<form:option value="" label=""/>
					<form:options items="${fns:getDictList('month')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>品类：</label>
				<form:select path="kaCategory.id" class="input-medium">
					<form:option value="" label="全部"/>
					<form:options items="${fns:getCategory() }" itemLabel="label" itemValue="value" htmlEscape="false"/>
				</form:select>
			</li>
			<li><label>货号：</label>
				<form:input path="code" htmlEscape="false" maxlength="20" class="input-medium"/>
			</li>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="btns"><input id="reset" class="btn btn-primary" type="reset" value="重置"/></li>
			<li class="btns"><input id="btnExport" class="btn btn-primary" type="button" value="导出"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed"  style="text-align:center;">
		<thead>
			<tr style="background-color:orange;">
				<!-- <th>年份</th> -->
				<th></th>
				<th></th>
				<!-- <th>商品编号</th> -->
				<th></th>
				<th></th>
				<th></th>
				<th colspan="3" style="text-align:center;">期初库存</th>
				<th colspan="3" style="text-align:center;">本期入库</th>
				<th colspan="3" style="text-align:center;">本期出库</th>
				<th colspan="3" style="text-align:center;">期末库存</th>
				<%--
				<th>备注</th>
				<th>排序</th>
				 <shiro:hasPermission name="ka:kaFinance:edit"><th>操作</th></shiro:hasPermission> --%>
			</tr>
			<tr>
 				<!-- <th>年份</th> -->
				<th>编号</th>
				<th style="text-align:center;">货号</th>
				<!-- <th>商品编号</th> -->
				<th style="text-align:center;">品类</th>
				<th style="text-align:center;">供应商</th>
				<th style="text-align:center;">单位</th>
				<th style="text-align:center;">数量</th>
				<th style="text-align:center;">单价</th>
				<th style="text-align:center;">成本</th>
				<th style="text-align:center;">数量</th>
				<th style="text-align:center;">单价</th>
				<th style="text-align:center;">成本</th>
				<th style="text-align:center;">数量</th>
				<th style="text-align:center;">单价</th>
				<th style="text-align:center;">成本</th>
				<th style="text-align:center;">数量</th>
				<th style="text-align:center;">单价</th>
				<th style="text-align:center;">成本</th>
				<%--
				<th>备注</th>
				<th>排序</th>
				 <shiro:hasPermission name="ka:kaFinance:edit"><th>操作</th></shiro:hasPermission> --%>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="kaFinance" varStatus="status">
			<tr style="text-align:center;">
 				<%-- <td><a href="${ctx}/ka/kaFinance/form?id=${kaFinance.id}">
					${fns:getDictLabel(kaFinance.year, 'year', '')}
				</a></td> --%>
				<td  style="text-align:center;">
					${status.index + 1}
				</td> 
				<td style="text-align:center;">
					${kaFinance.code}
				</td>
				<td  style="text-align:center;">
					${kaFinance.supply.name}
				</td>
				<td style="text-align:center;">
					${kaFinance.kaCategory.name}
				</td>
				<td style="text-align:center;">
					<%-- ${kaFinance.unit} --%>件
				</td>
				<td style="text-align:center;">
					<fmt:formatNumber type="number" value="${kaFinance.beginNum==0.0?'':kaFinance.beginNum}" pattern="0.00" maxFractionDigits="0"/>
				</td>
				<td style="text-align:center;">
					<fmt:formatNumber type="number" value="${kaFinance.beginNum>0.0?kaFinance.beginCost/kaFinance.beginNum:''}" pattern="0.00" maxFractionDigits="2"/> 
				</td>
				<td style="text-align:center;">
					${kaFinance.beginNum==0.0?'':kaFinance.beginCost}
				</td>
				<td style="text-align:center;">
					<fmt:formatNumber type="number" value="${kaFinance.checkinNum==0.0?'':kaFinance.checkinNum}" pattern="0.00" maxFractionDigits="0"/>
				</td>
				<td style="text-align:center;">
					<%-- ${kaFinance.checkinPrice} --%>
					<fmt:formatNumber type="number" value="${kaFinance.checkinNum>0.0?kaFinance.checkinCost/kaFinance.checkinNum:''}" pattern="0.00" maxFractionDigits="2"/> 
				</td>
				<td style="text-align:center;">
					${kaFinance.checkinNum==0.0?'':kaFinance.checkinCost}
				</td>
				<td style="text-align:center;">
					<fmt:formatNumber type="number" value="${kaFinance.checkoutNum==0.0?'':kaFinance.checkoutNum}" pattern="0.00" maxFractionDigits="0"/>
					(<fmt:formatNumber type="number" value="${kaFinance.badNum==0.0?'0':kaFinance.badNum}" pattern="0.00" maxFractionDigits="0"/>)
				</td>
				<td>
					<fmt:formatNumber type="number" value="${kaFinance.checkoutNum>0.0?kaFinance.checkoutCost/kaFinance.checkoutNum:''}" pattern="0.00" maxFractionDigits="2"/>
					
				</td>
				<td style="text-align:center;">
					${kaFinance.checkoutNum==0.0?'':kaFinance.checkoutCost}
				</td>
				<td style="text-align:center;">
					<fmt:formatNumber type="number" value="${kaFinance.endNum==0.0?'':kaFinance.endNum}" pattern="0.00" maxFractionDigits="0"/>
				</td>
				<td style="text-align:center;">
					<fmt:formatNumber type="number" value="${kaFinance.endNum>0.0?kaFinance.endCost/kaFinance.endNum:''}" pattern="0.00" maxFractionDigits="2"/>
				</td>
				<td style="text-align:center;">
					${kaFinance.endNum==0.0?'':kaFinance.endCost}
				</td>
				
				<%-- <td>
					${kaFinance.note}
				</td>
				<td>
					${kaFinance.sort}
				</td> --%>
				<%-- <shiro:hasPermission name="ka:kaFinance:edit"><td>
    				<a href="${ctx}/ka/kaFinance/form?id=${kaFinance.id}">修改</a>
					<a href="${ctx}/ka/kaFinance/delete?id=${kaFinance.id}" onclick="return confirmx('确认要删除该财务报表吗？', this.href)">删除</a>
				</td></shiro:hasPermission> --%>
			</tr>
		</c:forEach>
		<c:if test="${page.lastPage}">
		<tr style="text-align:center;">
 				<td>统计</td>
				<td>
				</td> 
				<td style="text-align:center;">
				</td>
				<td style="text-align:center;">
					${kaFinance.supply.name}
				</td>
				<td style="text-align:center;">
				</td>
				
				<td style="text-align:center;">
				<fmt:formatNumber type="number" value="${beginNumTotal}" pattern="0.00" maxFractionDigits="0"/>
				</td>
				<td style="text-align:center;">
				</td>
				<td style="text-align:center;">${beginCostTotal}
				</td>
				<td style="text-align:center;">
				<fmt:formatNumber type="number" value="${checkInNumTotal}" pattern="0.00" maxFractionDigits="0"/>
				</td>
				<td style="text-align:center;">
				</td>
				<td style="text-align:center;">${checkInCostTotal}
				</td>
				<td style="text-align:center;">
				<fmt:formatNumber type="number" value="${checkoutNumTotal}" pattern="0.00" maxFractionDigits="0"/>
				(<fmt:formatNumber type="number" value="${badNumTotal}" pattern="0.00" maxFractionDigits="0"/>)
				</td>
				<td>
				</td>
				<td style="text-align:center;">${checkoutCostTotal}
				</td>
				<td style="text-align:center;">
				<fmt:formatNumber type="number" value="${endNumTotal}" pattern="0.00" maxFractionDigits="0"/>
				</td>
				<td style="text-align:center;">
				</td>
				<td style="text-align:center;">${endCostTotal}
				</td>
			</tr>
			</c:if>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>